package com.sfms.enter_client;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        // 获取输入框和按钮
        EditText ipInput = findViewById(R.id.ipInput);
        Button connectButton = findViewById(R.id.connectButton);

        // 设置按钮点击事件
        connectButton.setOnClickListener(v -> {
            // 获取输入的IP地址
            String ipAddress = ipInput.getText().toString();
            // 跳转到 VideoActivity 并传递 IP 地址
            Intent intent = new Intent(MainActivity.this, VideoActivity.class);
            intent.putExtra("IP_ADDRESS", ipAddress); // 添加 IP 地址到 Intent
            // 完成页面跳转
            startActivity(intent);
        });

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
}